package com.intsig.airflow.web.util;

import java.util.Arrays;
import java.util.List;

/**
 * 计算hash值
 *
 * @author leo.jie (weixiao.me@aliyun.com)
 * @version 1.0
 * @organization bigdata
 * @website https://www.jielongping.com
 * @date 2021/3/17 11:34 上午
 * @since 1.0
 */
public class HashUtil {

    public static long toHash(String key) {
        int arraySize = 11113; // 数组大小一般取质数
        int hashCode = 0;
        for (int i = 0; i < key.length(); i++) {
            int letterValue = key.charAt(i) - 96;
            hashCode = ((hashCode << 5) + letterValue) % arraySize;
        }
        return hashCode;
    }


    public static void main(String[] args) {
        System.out.println(toHash("behavior_dag_online&&behavior.cs_device_person_backend_tag"));
        System.out.println(toHash("behavior_dag_online&&behavior.cs_device_person_backend_ta1"));
    }
}
